#include "tabelas.h"

void initialize_semantic_tables() {

	table_numbers = init_table(table_numbers);
	table_reserved_words = init_table(table_reserved_words);
	table_specials = init_table(table_specials);
	table_symbols = init_table(table_symbols);

	/* add reserved words */
	add(&table_reserved_words, "programa");
	add(&table_reserved_words, "funcao");
	add(&table_reserved_words, "retorna");
	add(&table_reserved_words, "procedimento");
	add(&table_reserved_words, "eh");
	add(&table_reserved_words, "registro");
	add(&table_reserved_words, "se");
	add(&table_reserved_words, "entao");
	add(&table_reserved_words, "senao");
	add(&table_reserved_words, "senaoSe");
	add(&table_reserved_words, "enquanto");
	add(&table_reserved_words, "loop");
	add(&table_reserved_words, "verdadeiro");
	add(&table_reserved_words, "falso");
	add(&table_reserved_words, "entrada");
	add(&table_reserved_words, "saida");
	add(&table_reserved_words, "inicio");
	add(&table_reserved_words, "fim");
	add(&table_reserved_words, "fimRegistro");
	add(&table_reserved_words, "fimSe");
	add(&table_reserved_words, "fimLoop");
	add(&table_reserved_words, "inteiro");
	add(&table_reserved_words, "real");
	add(&table_reserved_words, "booleano");
	add(&table_reserved_words, "string");
	add(&table_reserved_words, "E");
	add(&table_reserved_words, "OU");
	add(&table_reserved_words, "NAO");

}


int update_semantic_tables() {

	int index = -1;

	if (token.type == TOKEN_TYPE_INT_NUMBER)
		index = add(&table_numbers, token.value);
	else if (token.type == TOKEN_TYPE_RESERVED_WORD)
		index = add(&table_reserved_words, token.value);
	else if (token.type == TOKEN_TYPE_IDENTIFIER)
		index = add(&table_symbols, token.value);
	else if (token.type == TOKEN_TYPE_SPECIAL)
		index = add(&table_specials, token.value);

	//TALVEZ PRECISE CRIAR UMA TABELA PRA STRING. MAS NAO SE SE PRECISA NAO. ver melhor depois.

	return index;

}
